﻿	// Copyright 2010 Edmundo Pavel Soriano Morales

    // This file is part of eltokenizer.

    // eltokenizer is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License, or
    // (at your option) any later version.

    // eltokenizer is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.

    // You should have received a copy of the GNU General Public License
    // along with eltokenizer.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

namespace Tokenizer
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Count() > 0)
            {
                Console.WriteLine("Se eligio la carpeta: " + args[0]);

            }
            else
            {
                Console.WriteLine("No hay parametro para el path de la carpeta");

                Console.ReadLine();
                return;
            }
            var coleccionDocs = obtenColeccionDocumentos(args[0]);
            
            Console.WriteLine("Elige el orden deseado:\n [1]: Por frecuencia: \n [2]:Alfabéticamente: \n");
            string tipodeOrden = Console.ReadLine();
            coleccionDocs.ImprimeInfo(Int32.Parse(tipodeOrden), "juntos");
            
        }

        static public ColeccionDocumentos obtenColeccionDocumentos(string pathDirectorio)
        {
            List<string> filePaths = regresaNombresdeArchivos(pathDirectorio);
            List<Documento> listaDocumentos = new List<Documento>();
            foreach (var pathArchivo in filePaths)
            {
                var texto = File.ReadAllText(pathArchivo).ToLower();
                listaDocumentos.Add(new Documento(texto));
            }

            return new ColeccionDocumentos(listaDocumentos);
        }

            
      
       
        static public List<string> regresaNombresdeArchivos(string directorioElegido)
        {
            List<string> filePaths = (Directory.GetFiles(directorioElegido, "*.txt")).ToList();

            return filePaths;


        }

    }
}
